package cn.mgr.logistics.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import cn.mgr.logistics.activity.R;

public class GridImageAdapter extends BaseAdapter {
	private Context mContext;
	private String[] mTextValues;

	public GridImageAdapter(Context c) {
		mContext = c;
		mTextValues = new String[] { mContext.getString(R.string.my_favorite),
				mContext.getString(R.string.my_account),
				mContext.getString(R.string.recommend),
				mContext.getString(R.string.contact_us),
				mContext.getString(R.string.soft_update),
				mContext.getString(R.string.check_in) };
	}

	@Override
	public int getCount() {
		return mThumbIds.length;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup arg2) {
		View view = View.inflate(mContext, R.layout.grid_item, null);
		RelativeLayout rl = (RelativeLayout) view.findViewById(R.id.relaGrid);

		ImageView image = (ImageView) rl.findViewById(R.id.image);
		TextView text = (TextView) rl.findViewById(R.id.text);

		image.setImageResource(mThumbIds[position]);
		text.setText(mTextValues[position]);

		return rl;
	}

	// references to our images
	private Integer[] mThumbIds = { R.drawable.favorite, R.drawable.account,
			R.drawable.recommand, R.drawable.contact, R.drawable.update,
			R.drawable.mylocation };

	@Override
	public Object getItem(int position) {
		return position;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}
}
